/**
 * Created by hillchen on 2017/11/28 0028.
 */
import views from '../view/Views'
export default {
  positiveIntegerExp : /(^[1-9]\d*$)/,
  isPositiveInteger (_num) {
    return this.positiveIntegerExp.test(_num);
  },
  getVueComponent (_vueName) {
    return views[_vueName];
  },
  getViews () {
    return views;
  },
  menusConvertToMap (_menus) {
      let menusMap = new Map();
      let menusIterator = function (_menus) {
          for(let _menu of _menus){
              if(!menusMap.has(_menu.id)){
                  menusMap.set(_menu.id,_menu);
                  if(!!_menu.childrenMenu){
                      menusIterator(_menu.childrenMenu);
                  }
              }
          }
      }
      menusIterator(_menus);
      return menusMap;
  }

}
